package com.zkthink.ceres.order.entity;

import cn.afterturn.easypoi.excel.annotation.Excel;
import cn.afterturn.easypoi.excel.annotation.ExcelEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.annotation.IdType;
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableId;
import com.zkthink.base.entity.Entity;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.Range;
import java.time.LocalDateTime;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import lombok.experimental.Accessors;
import static com.zkthink.utils.DateUtils.DEFAULT_DATE_TIME_FORMAT;

import static com.baomidou.mybatisplus.annotation.SqlCondition.LIKE;

/**
 * <p>
 * 实体类
 * 用户支付成功后，供应商未发货前可退款
 * </p>
 *
 * @author JustArgo
 * @since 2020-05-20
 */
@Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("ceres_money_return")
@ApiModel(value = "MoneyReturn", description = "用户支付成功后，供应商未发货前可退款")
@AllArgsConstructor
public class MoneyReturn extends Entity<Long> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("商户编号")
    @TableField("tenant_code")
    private String tenantCode;

    @ApiModelProperty("用户id")
    @TableField(value = "mid")
    private Long mid;

    /**
     * 退款单编号
     */
    @ApiModelProperty(value = "退款单编号")
    @NotEmpty(message = "退款单编号不能为空")
    @Length(max = 32, message = "退款单编号长度不能超过32")
    @TableField(value = "return_code", condition = LIKE)
    @Excel(name = "退款单编号")
    private String returnCode;

    /**
     * 订单id
     */
    @ApiModelProperty(value = "订单id")
    @TableField("order_id")
    @Excel(name = "订单id")
    private Long orderId;

    /**
     * 订单编号
     */
    @ApiModelProperty(value = "订单编号")
    @Length(max = 32, message = "订单编号长度不能超过32")
    @TableField(value = "order_code", condition = LIKE)
    @Excel(name = "订单编号")
    private String orderCode;

    /**
     * 订单商品id列表
     */
    @ApiModelProperty(value = "订单商品id列表")
    @NotEmpty(message = "订单商品id列表不能为空")
    @Length(max = 1024, message = "订单商品id列表不能超过1024")
    @TableField(value = "order_product_ids", condition = LIKE)
    @Excel(name = "订单商品id列表")
    private String orderProductIds;

    /**
     * 状态：0-审核中 1-审核通过 2-审核不通过 3-退款中 4-退款完成 5-退款失败 6-撤销申请
     */
    @ApiModelProperty(value = "状态：0-审核中 1-审核通过 2-审核不通过 3-退款中 4-退款完成 5-退款失败 6-撤销申请")
    @TableField("status")
    @Excel(name = "状态：0-审核中 1-审核通过 2-审核不通过 3-退款中 4-退款完成 5-退款失败 6-撤销申请")
    private Integer status;

    /**
     * 上传的凭证
     */
    @ApiModelProperty(value = "上传的凭证")
    @NotEmpty(message = "上传的凭证不能为空")
    @Length(max = 255, message = "上传的凭证长度不能超过255")
    @TableField(value = "return_imgs", condition = LIKE)
    @Excel(name = "上传的凭证")
    private String returnImgs;

    /**
     * 货物状态：1-未收到货 2-已收到货
     */
    @ApiModelProperty(value = "货物状态：1-未收到货 2-已收到货")
    @NotNull(message = "货物状态：1-未收到货 2-已收到货不能为空")
    @TableField("goods_state")
    @Excel(name = "货物状态：1-未收到货 2-已收到货")
    private Integer goodsState;

    /**
     * 退款原因
     */
    @ApiModelProperty(value = "退款原因")
    @TableField("return_reason")
    @Excel(name = "退款原因")
    private Integer returnReason;

    /**
     * 退款描述
     */
    @ApiModelProperty(value = "退款描述")
    @Length(max = 256, message = "退款描述长度不能超过256")
    @TableField(value = "return_desc", condition = LIKE)
    @Excel(name = "退款描述")
    private String returnDesc;

    /**
     * 审核退款时的备注
     */
    @ApiModelProperty(value = "审核退款时的备注")
    @Length(max = 256, message = "审核退款时的备注长度不能超过256")
    @TableField(value = "return_money_remark", condition = LIKE)
    @Excel(name = "审核退款时的备注")
    private String returnMoneyRemark;

    /**
     * 申请退款金额
     */
    @ApiModelProperty(value = "申请退款金额")
    @TableField("apply_sum")
    @Excel(name = "申请退款金额")
    private Long applySum;

    /**
     * 真实退款金额
     */
    @ApiModelProperty(value = "真实退款金额")
    @TableField("real_return_sum")
    @Excel(name = "真实退款金额")
    private Long realReturnSum;

    /**
     * 第三方退款单号
     */
    @ApiModelProperty(value = "第三方退款单号")
    @Length(max = 256, message = "第三方退款单号长度不能超过256")
    @TableField(value = "third_return_no", condition = LIKE)
    @Excel(name = "第三方退款单号")
    private String thirdReturnNo;

    /**
     * 退款时间
     */
    @ApiModelProperty(value = "退款时间")
    @TableField("return_time")
    @Excel(name = "退款时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime returnTime;

    /**
     * 审核时间
     */
    @ApiModelProperty(value = "审核时间")
    @TableField("audit_time")
    @Excel(name = "审核时间", format = DEFAULT_DATE_TIME_FORMAT, width = 20)
    private LocalDateTime auditTime;

    /**
     * 当前版本 同一个订单可以申请多次，最近的版本为0
     */
    @ApiModelProperty(value = "当前版本 同一个订单可以申请多次，最近的版本为0")
    @NotNull(message = "当前版本 同一个订单可以申请多次，最近的版本为0不能为空")
    @TableField("current_version")
    @Excel(name = "当前版本 同一个订单可以申请多次，最近的版本为0")
    private Integer currentVersion;

    /**
     * 逻辑删除：1-删除 0-未删除
     */
    @ApiModelProperty(value = "逻辑删除：1-删除 0-未删除")
    @NotNull(message = "逻辑删除：1-删除 0-未删除不能为空")
    @TableField("is_delete")
    @Excel(name = "逻辑删除：1-删除 0-未删除")
    private Integer isDelete;


    @Builder
    public MoneyReturn(Long id, Long createUser, LocalDateTime createTime, Long updateUser, LocalDateTime updateTime, 
                    String returnCode, Long orderId, String orderCode, String orderProductIds, Integer status, String returnImgs,
                    Integer goodsState, Integer returnReason, String returnDesc, String returnMoneyRemark, Long applySum, Long realReturnSum, 
                    String thirdReturnNo, LocalDateTime returnTime, LocalDateTime auditTime, Integer currentVersion, Integer isDelete) {
        this.id = id;
        this.createUser = createUser;
        this.createTime = createTime;
        this.updateUser = updateUser;
        this.updateTime = updateTime;
        this.returnCode = returnCode;
        this.orderId = orderId;
        this.orderCode = orderCode;
        this.orderProductIds = orderProductIds;
        this.status = status;
        this.returnImgs = returnImgs;
        this.goodsState = goodsState;
        this.returnReason = returnReason;
        this.returnDesc = returnDesc;
        this.returnMoneyRemark = returnMoneyRemark;
        this.applySum = applySum;
        this.realReturnSum = realReturnSum;
        this.thirdReturnNo = thirdReturnNo;
        this.returnTime = returnTime;
        this.auditTime = auditTime;
        this.currentVersion = currentVersion;
        this.isDelete = isDelete;
    }

}
